import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import PowerBIDesigner from '../views/PowerBIDesigner.vue'
import DataModel from '../views/DataModel.vue'
import DataCleaning from '../views/DataCleaning.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: 'PowerBI Web版 - 数据可视化平台'
    }
  },
  {
    path: '/designer',
    name: 'PowerBIDesigner',
    component: PowerBIDesigner,
    meta: {
      title: 'PowerBI 设计器'
    }
  },
  {
    path: '/data-model',
    name: 'DataModel',
    component: DataModel,
    meta: {
      title: '数据模型 - PowerBI Web版'
    }
  },
  {
    path: '/data-cleaning',
    name: 'DataCleaning',
    component: DataCleaning,
    meta: {
      title: '数据清洗 - PowerBI Web版'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router